AC_INIT(nhns, engine alpha, http://code.google.com/p/n-hack-n-slash/)

AC_ARG_VAR(LUA_PATH, Lua install path)
AC_ARG_VAR(LUABIND_PATH, Luabind install path)
AC_ARG_VAR(BOOST_ROOT, Boost install path)
AC_ARG_VAR(PUGIXML_PATH, pugixml install path)
AC_ARG_VAR(SFML_PATH, SFML 2.0 path)

AC_MSG_NOTICE([Configuring MakefileShared])

echo ""
AC_PROG_CXX

AC_LANG(C++)

CPPFLAGS="$CPPFLAGS"

if [[ -n "$BOOST_ROOT" ]]
then
	CPPFLAGS="$CPPFLAGS -I$BOOST_ROOT"
else
	BOOST_ROOT=""
fi

if [[ -n "$LUA_PATH" ]]
then
	CPPFLAGS="$CPPFLAGS -I$LUA_PATH"
else
	LUA_PATH=""
fi

if [[ -n "$SFML_PATH" ]]
then
	CPPFLAGS="$CPPFLAGS -I$SFML_PATH -I$SFML_PATH/include/"
else
	SFML_PATH=""
fi

if [[ -n "$PUGIXML_PATH" ]]
then
	CPPFLAGS="$CPPFLAGS -I$PUGIXML_PATH"
else
	PUGIXML_PATH=""
fi

if [[ -n "$LUABIND_PATH" ]]
then
	CPPFLAGS="$CPPFLAGS -I$LUABIND_PATH"
else
	LUABIND_PATH=""
fi

AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset pow sqrt])

echo ""
AC_MSG_NOTICE([Checking for external dependencies])

AC_MSG_NOTICE([Checking for boost.])
AC_CHECK_HEADER([boost/config.hpp], [], [AC_MSG_ERROR([Boost not found.])])

echo ""
AC_MSG_NOTICE([Checking for lua])
AC_CHECK_HEADER([luaconf.h], [], [AC_MSG_ERROR([Lua not found.])])

echo ""
AC_MSG_NOTICE([Checking for luabind])
AC_CHECK_HEADER([luabind/config.hpp], [], [AC_MSG_ERROR([Luabind not found.])])

echo ""
AC_MSG_NOTICE([Checking for SFML 2.0])
AC_CHECK_HEADER([SFML/Config.hpp], [], [AC_MSG_ERROR([SFML not found.])])

echo ""
AC_MSG_NOTICE([Checking for pugixml])
AC_CHECK_HEADER([src/pugiconfig.hpp], [], [AC_MSG_WARN([pugixml not found. Development tools will not be able to compile])])

echo ""
AC_MSG_NOTICE([Dependency check done])

echo ""
echo ""
AC_OUTPUT(MakefileShared)
